<template>
  <div>
    <!-- 选择班次 -->
    <el-select
      v-model="value"
      @change="handleChange"
      placeholder="请选择"
      style="width: 100%"
      clearable
      filterable
      :disabled="disabled"
    >
      <el-option
        v-for="item in options"
        :key="item.id"
        :label="item.name"
        :value="item.id"
      >
      </el-option>
    </el-select>
  </div>
</template>
<script>
export default {
  data() {
    return {
      value: [],
      listQuery: {
        page: 1,
        limit: 999,
      },
      options: [],
    }
  },
  props: {
    defaultValue: String,
    disabled: {
      type: Boolean,
      default: false,
    },
  },
  watch: {
    defaultValue(v) {
      this.value = v
    },
  },
  mounted() {
    this.value = this.defaultValue
    this.getList()
  },
  methods: {
    async getList() {
      let res = await this.$store.dispatch('queryEduClasses', this.listQuery)
      this.options = res.data
    },
    handleChange(value) {
      this.$emit('emit', value)
    },
  },
}
</script>